#pragma once
#include <iostream>
#include <pthread.h>


class Mutex
{
public:
    Mutex(pthread_mutex_t* p_lock = nullptr)
        :_p_lock(p_lock)
    {}
    void lock()
    {
        if(_p_lock)pthread_mutex_lock(_p_lock);
    }
    void unlock()
    {
        if(_p_lock)pthread_mutex_unlock(_p_lock);
    }
    ~Mutex()
    {}
private:
    pthread_mutex_t* _p_lock;
};

class lockGroud
{
public:
    lockGroud(pthread_mutex_t* mutex)
        :_mutex(mutex)
    {
        _mutex.lock();
    }
    ~lockGroud()
    {
        _mutex.unlock();
    }
private:
    Mutex _mutex;
};